package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.Video;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * @author Xiao
 * @version 1.0
 * @description 查询小视频返回videoVO对象
 * @date 2021/11/2
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class VideoVO implements Serializable {
    private Long userId;
    private String avatar; //头像
    private String nickname; //昵称

    private String id;
    private String cover; //封面
    private String videoUrl; //视频URL
    private String signature; //发布视频时，传入的文字内容


    private Integer likeCount; //点赞数量
    private Integer hasLiked; //是否已赞（1是，0否）
    private Integer hasFocus; //是否关注 （1是，0否）
    private Integer commentCount; //评论数量

    public static VideoVO init(UserInfo userInfo, Video video) {
        VideoVO videoVO = new VideoVO();
        //copy用户属性
        BeanUtils.copyProperties(userInfo,videoVO);
        //copy视频属性
        BeanUtils.copyProperties(video,videoVO);
        videoVO.setCover(video.getPicUrl());
        videoVO.setId(video.getId().toHexString());
        videoVO.setSignature(video.getText());
        videoVO.setHasFocus(0);
        videoVO.setHasLiked(0);
        return videoVO;
    }
}
